package com.example.flow.flow.model;

import java.util.ArrayList;
import java.util.List;

/**
 * 流程节点
 *
 * @author tangaq
 * 2023/6/13
 */
public class ProcessModel extends BaseModel {
    private static final long serialVersionUID = -7141121965401087926L;

    /**
     * 任务节点
     */
    private List<NodeModel> nodes = new ArrayList<>();

    /**
     * 获取process定义的start节点
     *
     * @return
     */
    public StartModel getStart() {
        for (NodeModel node : nodes) {
            if (node instanceof StartModel) {
                return (StartModel) node;
            }
        }
        return null;
    }

    /**
     * 获取process定义的指定名称的节点
     *
     * @param nodeName
     * @return
     */
    public NodeModel getNode(String nodeName) {
        for (NodeModel node : nodes) {
            if (node.getName().equals(nodeName)) {
                return node;
            }
        }
        return null;
    }

    public List<NodeModel> getNodes() {
        return nodes;
    }

    public void setNodes(List<NodeModel> nodes) {
        this.nodes = nodes;
    }
}
